<?php $this->start('admin_menu')?>
	<?php echo $this->element('admin_menu', array('str_item' => 'galleries')) ?>
<?php $this->end(); ?>

<div class="index">
	<h2><?php echo __('Galleries'); ?></h2>
	<?php 	echo $this->Session->flash();
		echo $this->Session->flash('good');
		echo $this->Session->flash('bad'); ?>
	<div class="galleries">
		<div class='gallery-div folder-form' style="display: <?php echo isset($show_form) ? 'block' : 'none' ?>">
			<?php echo $this->Form->create('Gallery'); ?>
			<a href='#' class='fdicon'><?php echo $this->Html->image('folder.png') ?></a>
			<a href='#' class='fdname'>
				<?php echo $this->Form->input('name', array('label' => false, 
						'class' => 'ipt-new-fd required', 'value' => 'New Folder', 'maxlength' => 25)); ?>
			</a>
			<span><a href="#" id='submit-folder'>Save</a> | <a href='#' class='cancel-folder'>Cancel</a></span>
			<?php echo $this->Form->end(); ?>
		</div>
	<?php foreach ($galleries as $gallery): ?>
		<div class='gallery-div'>
			<?php echo $this->Html->link($this->Html->image('folder.png', 
																											array('alt' => $gallery['Gallery']['name'], 
																														'title' => $gallery['Gallery']['name'])), 
																	array('action' => 'view', $gallery['Gallery']['id']), 
																	array('class' => 'fdicon', 'escape' => false)) ?>

			<?php echo $this->Html->link($gallery['Gallery']['name'], array('action' => 'view', $gallery['Gallery']['id']), array('class' => 'fdname')); ?>
			<span><?php echo (count($gallery['Image']) > 0 ? count($gallery['Image']) . ' file(s)' : 'empty');  ?></span>
		</div>
	<?php endforeach; ?>
	</div>
<!--
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('id'); ?></th>
			<th><?php echo $this->Paginator->sort('name'); ?></th>
			<th><?php echo $this->Paginator->sort('created_at'); ?></th>
			<th><?php echo $this->Paginator->sort('created_by'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	<?php foreach ($galleries as $gallery): ?>
	<tr>
		<td><?php echo h($gallery['Gallery']['id']); ?>&nbsp;</td>
		<td><?php echo h($gallery['Gallery']['name']); ?>&nbsp;</td>
		<td><?php echo h($gallery['Gallery']['created_at']); ?>&nbsp;</td>
		<td><?php echo h($gallery['Gallery']['created_by']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('View'), array('action' => 'view', $gallery['Gallery']['id'])); ?>
			<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $gallery['Gallery']['id'])); ?>
			<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $gallery['Gallery']['id']), null, __('Are you sure you want to delete # %s?', $gallery['Gallery']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>-->
</div>
<div class='actionct'>
	<span class='btn-act'><span><?php echo $this->Html->link(__('New Gallery'), '#', array('class' => 'new-folder')); ?></span></span>
</div>

<?php $this->start('script') ?>
<script type="text/javascript">
    jQuery(document).ready(function(){
	var validator = jQuery('#GalleryAdminIndexForm').validate();
	    jQuery('.new-folder').click(function(){
				$('.folder-form').show();
			});
		jQuery('.cancel-folder').click(function(){
			jQuery('#GalleryAdminIndexForm')[0].reset();
						$('.folder-form').hide();
			 validator.resetForm();
		});
		jQuery('#submit-folder').click(function(){
			jQuery('#GalleryAdminIndexForm').submit();
		});
		
    });
</script>
<?php $this->end() ?>
